import request from '@/utils/request.js'

//注册
export const registerService = (registerData) => {
    var params = new URLSearchParams()
    for (let key in registerData) {
        params.append(key, registerData[key])
    }
    return request.post('/user/register', params)
}

//登录
export const loginService = (loginData)=>{
    var params = new URLSearchParams()
    for(let key in loginData){
        params.append(key,loginData[key])
    }
    return request.post('/user/login',params)
}

//获取用户信息
export const getUserInfoService = ()=>{
    return request.get('/user/userinfo')
}

//修改用户信息
export const updateUserInfoService = (updateData)=>{
    // 发送JSON格式数据
    return request.put('/user/updateUserInfo', updateData)
}

//修改用户密码
export const updatePasswordService = (updateData)=>{
    // 发送JSON格式数据
    return request.patch('/user/updatePassword', updateData)
}

//退出登录
export const logoutService = ()=>{
    return request.post('/user/logout')
}